﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MvcShop.Models.ViewDataModels
{
    public class FrontUserManageViewData
    {
        #region ==== Property =====
        public int PageIndex { get; set; }
        public int Count { get; set; }
        public int Total { get; set; }
        public string KeyWord { get; set; }
        public string UserAmount { get; set; }

        public IEnumerable<OrdersCenter> OrdersCenters { get; set; }
        public IEnumerable<FProductList> FProductList { get; set; }

        public IEnumerable<Orders> Orderses { get; set; }

        public IEnumerable<Remark> Remarks { get; set; }

        public IEnumerable<ProductsToRemarkModel> ProductsToRemarkModels { get; set; }
        #endregion

        #region ==== Methods ====
        public FrontUserManageViewData WithPageIndex(int pageIndex)
        {
            this.PageIndex = pageIndex;
            return this;
        }

        public FrontUserManageViewData WithCount(int count)
        {
            this.Count = count;
            return this;
        }

        public FrontUserManageViewData WithTotal(int pageSize)
        {
            this.Total = Math.Max((this.Count + pageSize - 1) / pageSize, 1); ;
            return this;
        }

        public FrontUserManageViewData WithKeyWord(string keyWord)
        {
            this.KeyWord = keyWord;
            return this;
        }

        public FrontUserManageViewData WithUserAmount(string userAmount)
        {
            this.UserAmount = userAmount;
            return this;
        }

        public FrontUserManageViewData WithOrdersCenters(IEnumerable<OrdersCenter> ordersCenters) 
        {
            this.OrdersCenters = ordersCenters;
            return this;
        }

        public FrontUserManageViewData WithFProductList(IEnumerable<FProductList> fProductList)
        {
            this.FProductList = fProductList;
            return this;
        }

        public FrontUserManageViewData WithOrderses(IEnumerable<Orders> orderses)
        {
            this.Orderses = orderses;
            return this;
        }

        public FrontUserManageViewData WithRemarks(IEnumerable<Remark> remarks)
        {
            this.Remarks = remarks;
            return this;
        }

        public FrontUserManageViewData WithProductsToRemarkModels(IEnumerable<ProductsToRemarkModel> productsToRemarkModels)
        {
            this.ProductsToRemarkModels = productsToRemarkModels;
            return this;
        }
        #endregion
    }

    public static class UserManageView
    {
        public static FrontUserManageViewData Data { get { return new FrontUserManageViewData(); } }
    }
}
